#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=200;

long long max(long long a, long long b) {
  return a>b ? a : b;
}

void sort(long long a[], long long b[], int l, int r) {
  int i=l, j=r;
  long long mid=a[(l+r)/2], t;
  for (; i<=j; ) {
    for (; a[j]>mid; j--);
    for (; a[i]<mid; i++);
    if (i<=j) {
      t=a[i], a[i]=a[j], a[j]=t;
      t=b[i], b[i]=b[j], b[j]=t;
      i++, j--;
    }
  }
  if (i<r) {
    sort(a, b, i, r);
  }
  if (j>l) {
    sort(a, b, l, j);
  }
}

long long calcOnce(long long len, long long p[], long long s[], int n, long long m) {
  long long ret=0, last=0;
  int i=1;
  for (i=1; i<=n && s[i]<len; i++) {
    ret += p[i]*(s[i]-last);
    if (ret>m) {
      return -1;
    }
    last = s[i];
  }
  if (i>n) {
    return -1;
  } else {
    return ret+(len-last)*p[i];
  }
}

bool cmp(long long a, long long b, long double c) {
  return a<=c/b;
}

long long calcCost(long long x, long long p[], long long s[], int n, long long f, long long len, long long m) {
  long long t1=calcOnce(len/x, p, s, n, m), t2=calcOnce(len/x+1, p, s, n, m);
  if (len%x) {
    if (t1>0 && t2>0 && t1<=m && t2<=m && cmp(t1, x-(len%x), m) && cmp(t2, len%x, m) && cmp(f, x, m)) {
      return t1*(x-len%x)+t2*(len%x)+f*x;
    } else {
      return -1;
    }
  } else {
    if (t1>0 && t1<=m && cmp(t1, x, m) && cmp(f, x, m)) {
      return (t1+f)*x;
    } else {
      return -1;
    }
  }
}

long long solve(long long x, long long p[], long long s[], int n, long long f, long long m) {
  long long ret=0;
  for (long long l=1, r=10000000000000000, mid; l<=r; ) {
    mid = (l+r)/2;
    long long t=calcCost(x, p, s, n, f, mid, m);
    if (t<=m && t>0) {
      l = mid+1;
      ret = mid;
    } else {
      r = mid-1;
    }
  }
  return ret;
}

int main() {
  freopen("food.in", "r", stdin);
  freopen("food.out", "w", stdout);

  static long long p[maxn+2], s[maxn+2];
  long long maxp=0, m, f;
  int n;
  scanf("%lld %lld %d", &m, &f, &n);
  for (int i=1; i<=n; i++) {
    scanf("%lld %lld", p+i, s+i);
    s[i]++;
    maxp = max(maxp, p[i]);
  }
  sort(s, p, 1, n);

  int nn=0;
  for (int i=1; i<=n; i++) {
    for (; nn>0 && p[nn]>=p[i]; nn--);
    p[++nn] = p[i];
    s[nn] = s[i];
  }
  n = nn;

  long long ans=0;
  for (long long l=1, r=10000000000000000, mid1, mid2, mid; l<r; ) {
    mid = (l+r)/2;
    mid1 = (l+mid)/2, mid2 = (mid+r)/2;
    long long t1=solve(mid1, p, s, n, f, m), t2=solve(mid2, p, s, n, f, m);
    if (t1<t2) {
      l = mid1+1;
      ans = max(ans, t2);
    } else {
      r = mid2-1;
      ans = max(ans, t1);
    }
  }

  printf("%lld\n", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
